<template>
	<view class="warp">
	   <view style="display:flex;justify-content: space-between;margin-top:20upx">
	   	<view style="width:80%;display:flex">
	   		<!-- <image v-if="evels.dimg" mode="aspectFill" style="width:200upx;height:200upx;border-radius: 20rpx;" :src="uploadFilePath+evels.dimg"></image>
	   		<image v-else mode="aspectFill" style="width:200upx;height:200upx;"  src="../../../static/images/goods.png"></image> -->
	   		<view style="line-height: 1.5rem;">
	   			<view style="font-size:1rem;font-weight: bold;">{{evels.dishesName}}</view>
	   			<view style="font-size:1rem" v-if="evels.qcode">取餐码：<text>{{evels.qcode}}</text></view>
	   			<view style="font-size:1rem;color:#666">{{evels.createTime}}</view>
	   		</view>
	   	</view>
	   	<view style="line-height: 1.5rem;">
	   		<view style="font-size:1rem;font-weight: bold;">￥{{evels.idisPrice}}</view>
	   		<view style="font-size:1rem">共{{evels.ipayNum}}件</view>
	   	</view>
	   </view>
	 
		  <view style="font-size:1.1rem;margin-top:20px">你对商家/菜品满意吗？</view>
		  <view style="display:flex;margin-top:10px">
			  <view>满意度</view>
			  <uni-rate v-model="evels.score" active-color="#FA3534" :margin="10" size="20" @change="changeScore"/>
		  </view>
			<textarea
			  maxlength="100"
			  autosize
			  v-model="evels.commentContent"
			  placeholder="口味如何,对商家满意吗？"
			  style="width:96%;padding:10rpx;background-color:#F7F8FA;margin-top:10px;"
			/>
	  <view style="width:96%;position:fixed;bottom:20rpx;left:50%;right:50%; transform: translate(-50%, -50%);" @click="addEvelute">
	    <u-button  color="#F66B71" round size="large">提交评价</u-button>
	  </view>
	</view>
</template>

<script>
	import Config from '@/util/index.js'
	import {
	 saveEvalate,evaluteList
	} from '@/api/order'
	export default{
		data(){
			return{
				sppj:'',
				evels:{
					sId: null,
					orderId: null,
					dishesId:null,
					score: 1,
					commentContent: null,
					displayFlag: null,
					replyContent: null,
					createBy: null,
					createTime: null,
					updateBy: null,
					updateTime: null
				},
				uploadFilePath:'',
				fileList:[],
				goosinfo:[],
				oid:''
			}
		},
		onLoad(options) {
			let row = JSON.parse(options.parsData)
		    this.evels=JSON.parse(options.parsData)
			console.log("evels",this.evels)
			this.evels.orderId = row.ordId
			this.evels.score = 2
			this.evels.createBy = uni.getStorageSync('createBy')
			this.uploadFilePath = Config.get('apiUrl')
		},
		methods:{
			changeScore(val){
				console.log("val",val)
				// this.evels.score = val-1
				console.log("score",this.evels.score)
			},
			addEvelute(){
				console.log("this.evels",this.evels)
				if(this.evels.commentContent==null || this.evels.commentContent==""){
					uni.showToast({
						title:"评价内容不能为空",
						icon: 'none',
						duration: 2000
					});
					return false
				}
				saveEvalate(this.evels).catch(res=> {
				    if (res.data.code == 200) {
				      uni.showToast({
				        title: '评论成功',
				        icon: 'none',
				        duration: 2000,
						complete: () => {
						  
						}
				      });
					  uni.navigateTo({
					  	url:'../my/order/index'
					  })
				    } else {
				      uni.showToast({
				        title: res.data.msg,
				        icon: 'none',
				        duration: 2000
				      });
				    }
				})
			}
		}
	}
</script>

<style>
	.pjnr{width:96%;color:#666;font-size:1rem;background:#f5f5f5;margin:auto;padding:10rpx}
	.pjnr image{width:100rpx;height:100rpx}
	.warp{padding:20rpx}
	.areatxt{width:100%;height:100%;min-height:300rpx;margin:20rpx auto;border:1px solid #f3f3f6}
	.gsorder{width: 100%;display:flex;}
	.gsorder image{width:5rem;height:5rem;object-fit:cover;display:block}
</style>
